package com.example.testproject.activity

import android.os.Bundle
import android.util.Log
import android.util.SparseArray
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.GridLayoutManager
import com.example.testproject.R
import com.example.testproject.adapter.RvAnalysisAdapter
import kotlinx.android.synthetic.main.recylcer_view.*

/**
 *
 * @ClassName: RecyclerViewAnalysisActivity
 * @Author: android 超级兵
 * @CreateDate: 11/3/21$ 10:25 AM$
 * TODO RecyclerView 源码分析
 */
class RecyclerViewAnalysisActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.recylcer_view)

        val testList = SparseArray<String>()
        testList.put(0, "测试00")
        testList.put(0, "测试01")
        testList.put(0, "测试02")
        testList.put(3, "测试3")
        testList.put(2, "测试2")
        testList.put(5, "测试5")
        testList.put(4, "测试4")

        repeat(testList.size()){
            Log.i("结果为:", testList.valueAt(it))
        }

        val rvAnalysisAdapter = RvAnalysisAdapter((0..1000).map { "$it" }.toList())

        rootRecyclerView.layoutManager = GridLayoutManager(this, 7)

        rootRecyclerView.adapter = rvAnalysisAdapter
    }
}